﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Security;

namespace SocialCee.Authorization
{
    /// <summary>
    /// TODO
    /// Error handling
    /// Return specific messages
    /// Check all possible items
    /// Other overloaded methods
    /// </summary>
    public class UserManager
    {
        #region Create User
        /// <summary>
        /// Create user
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public static MembershipUser CreateUser(string username, string password)
        {
            if (!Helpers.PasswordStrength.CheckPasswordComplexity(password))
                return null;

            return Membership.CreateUser(username, password);
        }

        /// <summary>
        /// Create user
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="email"></param>
        /// <returns></returns>
        public static MembershipUser CreateUser(string username, string password, string email)
        {
            return Membership.CreateUser(username, password, email);
        }

        /// <summary>
        /// Create user
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="email"></param>
        /// <param name="passwordQuestion"></param>
        /// <param name="passwordAnswer"></param>
        /// <param name="isApproved"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public static MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, out System.Web.Security.MembershipCreateStatus status)
        {
            return Membership.CreateUser(username, password, email, passwordQuestion, passwordAnswer, isApproved, out status);
        }

        /// <summary>
        /// Create user
        /// </summary>
        /// <param name="username"></param>
        /// <param name="password"></param>
        /// <param name="email"></param>
        /// <param name="passwordQuestion"></param>
        /// <param name="passwordAnswer"></param>
        /// <param name="isApproved"></param>
        /// <param name="providerUserKey"></param>
        /// <param name="status"></param>
        /// <returns></returns>
        public static MembershipUser CreateUser(string username, string password, string email, string passwordQuestion, string passwordAnswer, bool isApproved, object providerUserKey, out System.Web.Security.MembershipCreateStatus status)
        {
            return Membership.CreateUser(username, password, email, passwordQuestion, passwordAnswer, isApproved, providerUserKey, out status);
        }
        #endregion

        #region Login
        /// <summary>
        /// Create user
        /// Do not foget to set it in Authentication object
        /// </summary>
        /// <param name="userName"></param>
        /// <param name="password"></param>
        /// <returns></returns>
        public static bool Login(string userName, string password)
        {
            if (Membership.ValidateUser(userName, password))
            {
                return true;
            }
            else
                return false;

        }
        #endregion
    }
}
